<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        #app{
            width: 800px;
            height: 300px;
            margin: 100px auto;
            padding: 10px;
            border: 1px solid #ccc;
            box-shadow: 0 0 10px #ccc;
            text-align: center;
        
        }

        .goods{
            height: 250px;
            border: 1px solid gray;
            display: flex;
            flex-direction: column;
            justify-content: space-around;
        }
        .items{
            display: 1;
            width: 98%;
            height: 50px;
            margin: 0 auto;
            border: 1px solid gray;
            text-align: center;
            line-height: 50px;
        }
        button{
            width: 80px;
            height: 40px;
        }
    </style>
</head>
<body>
    <div id="app">
        <p>欢迎光临_vue开发的收银系统_水果店</p>
        <div class="goods">
            <div class="items">
                <h3>苹果 10￥/斤，折扣 &lt;8折&gt;</h3>
            </div>
            <div class="items">
                请输入你要购买的斤数<input type="text" v-model="buyNum">
            </div>
            <div class="items">
                <button @click="checkout()">结账买单~</button>
            </div>
            <div class="items">
                <p>结账单:总价:{{totalPrice}}￥元 折后价: {{discountPrice}}￥元 省了: {{save}}￥元</p>
            </div>
        </div>
    </div>

    <script src="../vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                buyNum: 0,
                totalPrice: 0,
                discountPrice: 0,
                save: 0
            },
            methods: {
                checkout(){
                    this.totalPrice = 10 * this.buyNum
                    this.discountPrice = this.totalPrice * 0.8
                    this.save = this.totalPrice - this.discountPrice
                    return (this.totalPrice,this.discountPrice,this.save)
                }
            }
        })
    </script>
</body>
</html>